為 Git 管理下的檔案,自動加上 Revision 或 Id 資訊
這個功能在 cvs 及 svn 上已經很久了,沒有道理 git 沒有 -- timchen119 如是說。 於是在 timchen119 『使徒提姆』 的幫助下,我找到了 git 的作法。
ident $Id$
$ echo '*.txt ident' >> .gitattributes $ echo '$Id$' > test.txt $ rm text.txt $ git checkout -- text.txt $ cat test.txt $Id: 42812b7653c7b88933f8a9d6cad0ca16714b9bb3 $
export-subst $Format:$
$ echo 'Last commit date: $Format:%cd$' > LAST_COMMIT $ echo "LAST_COMMIT export-subst" >> .gitattributes $ git add LAST_COMMIT .gitattributes $ git commit -am 'adding LAST_COMMIT file for archives' $ git archive HEAD | tar x LAST_COMMIT -O Last commit date: $Format:Tue Apr 21 08:38:48 2009 -0700$
make export-subst like SVN $ID$ format
110碼:AAA2369 $> echo '*.txt export-subst' >> .gitattributes 110碼:AAA2369 $> echo 'Id: $Format:%t %ai %an$' > format.txt 110碼:AAA2369 $> git commit -am 'adding format.txt file for archives' 110碼:AAA2369 $> git archive HEAD | tar x format.txt -O Id: 8cdd4c8 2009-12-24 22:12:20 +0800 lloyd huang
more $Format:PLACEHOLDERS$
$ man git-log search "placeholders" <-- this keyword
- %H: commit hash
- %h: abbreviated commit hash
- %T: tree hash
- %t: abbreviated tree hash
- %P: parent hashes
- %p: abbreviated parent hashes
- %an: author name
Posted by Lloyd Huang in General on December 24, 2009